package com.issoft.studentresitor.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.issoft.studentresitor.domain.pojo.Registration;
import com.issoft.studentresitor.domain.query.RegistrationQuery;
import com.issoft.studentresitor.domain.vo.RegistrationVo;
import com.issoft.studentresitor.mapper.RegistrationMapper;
import com.issoft.studentresitor.service.IRegistrationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.issoft.studentresitor.utils.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author GJH
 * @since 2025-09-14
 */
@Service
public class RegistrationServiceImpl extends ServiceImpl<RegistrationMapper, Registration> implements IRegistrationService {
    @Autowired
    private RegistrationMapper registrationMapper;
    @Override
    public PageResult<RegistrationVo> queryRegisPage(RegistrationQuery query) {
        PageHelper.startPage(query.getPage(), query.getPageSize());
        List<RegistrationVo> registrationVos = registrationMapper.queryRegistrationPage(query);
        Page<RegistrationVo> pageResult = (Page<RegistrationVo>) registrationVos;
        return new PageResult<>(pageResult.getTotal(), pageResult.getResult());
    }
}
